package common

import (
	"github.com/pkg/errors"
	"gopkg.in/yaml.v3"
	"io/ioutil"
)

type Config struct {
	Host   []string `yaml:"Host"`
	Broker []string `yaml:"Broker"`
	Group  string   `yaml:"Group"`
}

func GetConfig() (cfg Config, err error) {
	yamlFile, err := ioutil.ReadFile("./config/config.yml")
	if err != nil {
		return cfg, errors.Wrap(err, "ERR: fail to get config")
	}
	err = yaml.Unmarshal(yamlFile, &cfg)
	if err != nil {
		return cfg, errors.Wrap(err, "ERR: fail to get config")
	}
	return
}
